An extended adaptive multi-rate wideband (AMR-WB+) codec is a voice audio codec, which is capable of selecting a voice coding mode according to signal characteristics, for example, algebraic code excited linear prediction (ACELP) coding, or selecting an audio coding mode, for example, transform coded excitation (TCX) coding. At a closed-loop encoding end of the AMR-WB+ codec, the coding modes of both TCX and ACELP are adopted for coding an input audio signal, and signal-to-noise ratios of the signal after being coded by the two coding modes are compared. If the signal noise ratio (SNR) of the signal coded by the TCX coding mode is higher, data coded by the TCX coding mode serves as a bitstream and is sent to a receiving end; otherwise, data coded by the ACELP coding mode serves as a bitstream and is sent to the receiving end.
The TCX coding mode is classified into three types: TCX256 (256 sampling points are taken as one coding unit), TCX512 (512 sampling points are taken as one coding unit) and TCX1024 (1024 sampling points are taken as one coding unit). At the closed-loop encoding end of the AMR-WB+, when the TCX1024 mode is adopted for coding a data frame (briefly referred to as a TCX1024 frame below), a part of the frame is lost, and if the previous frame is also a TCX1024 frame, the previous correct frame may serve as a compensation basis to compensate the lost frame, and various compensation modes may be adopted, including spectrum interpolation and linear prediction.
The spectrum interpolation of the compensation mode includes performing interpolations on amplitude and phase respectively, which is based on the characteristic that the amplitude and phase of a data signal both have certain continuity. The amplitude interpolation includes the following steps.
A spectrum amplitude of a previous frame is calculated by: oldA[k]=|old{circumflex over (X)}(k)|, k=1, 2, . . . .
A spectrum amplitude of a current frame is calculated by: A[k]=|{circumflex over (X)}(k)|, k=1, 2, . . . .
An amplitude gain is calculated according to a spectrum amplitude in the current frame that is not lost and has a non-zero amplitude and a spectrum amplitude in the previous frame at a corresponding position by:
      gain    =                                        ∑                          k              ,                                                A                  ⁡                                      [                    k                    ]                                                  ≠                0                                              ⁢                                    A              ⁡                              [                k                ]                                      2                                                ∑                          k              ,                                                oldA                  ⁡                                      [                    k                    ]                                                  ≠                0                                              ⁢                      old            ⁢                                                  ⁢                                          A                ⁡                                  [                  k                  ]                                            2                                            ,      k    =    1    ,  2  ,  …
Therefore, a spectrum amplitude of a lost frame is calculated based on the gain calculated above by: A[k]=gain·oldA[k].
Before introducing the phase interpolation, a data transmission mode through packetization is illustrated. The raw data are [0,1,2,3,4,5,6,7,8, . . . ], in which [0,1,2,3] respectively indicate a first, second, third, and fourth datum, and so forth. Accordingly, the data are divided into four sub-frames as follows:
Sub-frame 1 {[0,1,2,3], [16,17,18,19], . . . }, sub-frame 2 {[4,5,6,7], [20,21,22,23], . . . }, sub-frame 3 {[8,9,10,11], [24,25,26,27], . . . }, and sub-frame 4 {[12,13,14,15], [28,29,30,31], . . . }.
If a certain sub-frame is lost when receiving data, compensation is required by using a previously-received correct frame. The compensation is similar to the principle of the amplitude interpolation, i.e., processing by using the phase information of the previously-received correct frame. For example, if the data frame [K+1, . . . , K+N−1] is lost when receiving data, a compensation can be made by using the correctly received K and K+N.
It is assumed that φ(K) and φ(K+N) are already known, and the phase values between them can be interpolated by the following formula:
                              φ          ^                ⁡                  (          k          )                    =                                    φ            ^                    ⁡                      (                          k              -              1                        )                          +                  Δ          ⁢                                          ⁢          old          ⁢                                          ⁢                      φ            ⁡                          (              k              )                                      +                  Δφ          c                      ,          k      =              K        +        1              ,    …    ⁢                  ,          K      +      N      -      1                  wherein      ,                          ⁢                        Δ          ⁢                                          ⁢          old          ⁢                                          ⁢                      φ            ⁡                          (              k              )                                      =                              old            ⁢                                                  ⁢                          φ              ⁡                              (                k                )                                              -                      old            ⁢                                                  ⁢                          φ              ⁡                              (                                  k                  -                  1                                )                                                        ,      and        ⁢                            Δ      ⁢                          ⁢              φ        c              =                                        [                                          φ                ⁡                                  (                                      K                    +                    N                                    )                                            -                              φ                ⁡                                  (                  K                  )                                                      ]                    -                      [                                          old                ⁢                                                                  ⁢                                  φ                  ⁡                                      (                                          K                      +                      N                                        )                                                              -                              old                ⁢                                                                  ⁢                                  φ                  ⁡                                      (                    K                    )                                                                        ]                          N            .      
Each data string in the lost sub-frame needs to be re-calculated. For example, if the sub-frame 2 is lost, [4,5,6,7] and [20,21,22,23] both need to calculate the Δφc once, and so forth.
For φ(K) and φ(K+N) of the correctly received data, several value acquisition modes in different circumstances are illustrated below. In a circumstance that taking no consideration at the two ends, i.e., an error data string has correctly received data on two sides thereof, for example, when the sub-frame 1 is lost, the data string [16,17,18,19] is lost, the data [15] and [20] are correctly received, and both φ(K) and φ(K+N) get the actual data. If the data loss occurs at a front end of the frame, i.e., the lost data does not have correct data at the front end thereof, K=0, φ(K)=φ(0)=0, and φ(K+N) acquires an actual value. If the data loss occurs at a rear end of the frame, i.e., the lost data does not have correct data at the rear end thereof, φ(K+N)=0, and φ(K) acquires an actual value.
However, in the existing compensation solution of the AMR-WB+ codec, the compensation cannot be performed unless the current frame is a TCX1024 and the previous frame is also a TCX1024, and the current lost frame is compensated according to the data of the previous correct frame. FIG. 1 is a schematic flow chart of a frame compensation method in the related art. Referring to FIG. 1, the method includes the following steps.
In step 101, it is judged whether a data loss occurs in a received data frame, i.e., whether the data frame is a lost frame or not, and if a data loss does not occur in a received data frame, a normal decoding operation is performed.
In step 102, it is judged whether the current lost frame is a TCX frame or not, and if the current lost frame is the TCX frame, step 103 is performed; otherwise, a corresponding non-TCX frame loss processing is performed on the lost frame. As the AMR-WB+ codec only adopts the coding modes of TCX and ACELP, if the lost frame is not a TCX frame, i.e., the lost frame is an ACELP frame, a frame loss processing under the ACELP coding mode is performed.
In step 103, it is judged whether the lost frame is a TCX1024 frame or not, and if the lost frame is the TCX1024 frame, step 104 is performed; otherwise, comfort noises are filled into the position of the lost frame.
In step 104, it is judged whether the previous frame is a TCX1024 frame or not, and if the previous frame is the TCX1024 frame, step 105 is performed; otherwise, comfort noises are filled into the position of the lost frame.
In step 105, an amplitude interpolation is performed on the previous frame, and the specific amplitude interpolation manner has been described above.
In step 106, a phase interpolation is performed on the previous frame to obtain a compensated data frame, and the specific phase interpolation manner has been described above.
The method for compensating a TCX1024 frame provided in the related art is only applicable to the compensation of frames in a single format (TCX1024 frame). When the correct frame or lost frame is in a format other than the TCX1024 frame, filling comfort noises is the only way for processing, which affects the reception quality at the receiving end to some extent.